/*
 * Created by SharpDevelop.
 * User: MyWife
 * Date: 9/30/2010
 * Time: 4:45 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using popLib;

namespace TaskNoteManager
{
	/// <summary>
	/// Description of PickTimeForm.
	/// </summary>
	public partial class PickTimeForm : Form
	{
		public int Result = 0;
		
		public PickTimeForm( string time )
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			try{
				dateTimePicker1.Value = DateTime.ParseExact( time, "dddd dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture );
			}catch{}		
			
			monthCalendar1.DateSelected += delegate(object sender, DateRangeEventArgs e) {				
				dateTimePicker1.Value = new DateTime( e.Start.Year,  
				                                     e.Start.Month, 
				                                     e.Start.Day, 
				                                     dateTimePicker1.Value.Hour, 
				                                     dateTimePicker1.Value.Minute, 
				                                     dateTimePicker1.Value.Second, 
				                                     dateTimePicker1.Value.Millisecond );
			};
			
			dateTimePicker1.ValueChanged += delegate(object sender, EventArgs e) { 
				monthCalendar1.SelectionStart = dateTimePicker1.Value;
			};
			
			
			button1.Click+= delegate { 
				this.Tag = dateTimePicker1.Value;
				Result = 1;
				this.Close();
			};
			
			button2.Click += delegate { 
				Result = 0;
				this.Close();
			};
			
			button3.Click+= delegate { 
				Result = -1;
				this.Close();
			};
		}
	}
}
